<?php
    @include_once("conn.php");

    $obj = array();

    $account = $_POST["account"];
    $pwd = $_POST["pwd"];

    if(!($account&&$pwd)){
        $obj["status"] = false;
        $obj["detail"] = "请输入完整的参数";
        exit(json_encode($obj));
    }

    $sql = "select * from `userinfo` where user = '$account' or phone = '$account' or email = '$account'";

    $result = mysqli_query($conn,$sql);

    $item = mysqli_fetch_assoc($result);

    if($item){
        if($pwd == $item["pwd"]){
            $obj["status"] = true;
            $obj["detail"] = "登录成功";
            setcookie("lgc",$item["user"],time()+60*60*24*7,"/");
        }else{
            $obj["status"] = false;
            $obj["detail"] = "账号或密码错误";
        }
    }else{
        $obj["status"] = false;
        $obj["detail"] = "该账号未注册";
    }
    echo json_encode($obj);
?>